﻿using Newtonsoft.Json;
using System;
using System.Text;

namespace HappyStudent.CfgLoad
{
    internal class CfgLoadException : FormatException
    {
        public CfgLoadException(string message, Exception innerException) : base(message, innerException)
        {
        }

        public static void JsonReadException(string modName, string jsonName, JsonReaderException e)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($"The mod ({modName})  has the wrong json file ({jsonName}).");
            sb.Append("Please check if there is an empty id or a structure error.");
            sb.AppendLine(string.Format("Error at path:{0},line:{1},positon:{2}",e.Path,e.LineNumber,e.LinePosition));
            string text = sb.ToString();
            throw new CfgLoadException(text,e);
        }
    }
}
